package com.loan.entity;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.io.Serializable;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class ResponseResult<T> implements Serializable {
    /**
     * 响应码
     *      200:成功
     *      400:失败
     */
    private int code;

    /**
     * 提示信息
     */
    private String message;

    /**
     * 数据
     */
    private T data;

    /**
     * 成功,设置数据
     * @param data
     */
    public ResponseResult(T data) {
        this.code= 200;
        this.message="suc";
        this.data = data;
    }

    /**
     * 失败,无返回数据,设置状态码和提示信息
     * @param code
     * @param message
     */
    public ResponseResult(int code, String message) {
        this.code = code;
        this.message = message;
        this.data = null;
    }

    /**
     * 成功,没有数据
     */
    public static final ResponseResult<Void> SUCCESS = new ResponseResult<>(200,"suc",null);

    /**
     * 失败,没有数据
     */
    public static ResponseResult<Void> FAIL = new ResponseResult<>(400,"fail",null);

}
